from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_session import Session
from config import *


# 配置数据库
db = SQLAlchemy()
redis_store = None


def create_app(config_name):
    app = Flask(__name__)
    from info.modules.index import blue_index
    app.register_blueprint(blue_index)
    app.config.from_object(config_name)

    Session(app)
    global redis_store
    redis_store = redis.StrictRedis(host=config_name.REDIS_HOST, port=config_name.REDIS_PORT)

    return app
